import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      redirect: '/login',
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/LoginView.vue'), // 登录页
    },
    {
      path: '/dashboard',
      name: 'dashboard',
      component: () => import('../layouts/BasicLayout.vue'), // 使用基础布局
      redirect: '/dashboard/workbench',
      children: [
        {
          path: 'workbench',
          name: 'workbench',
          component: () => import('../views/dashboard/WorkbenchView.vue'), // 工作台
        },
        {
          path: 'tenant-management',
          name: 'tenantManagement',
          component: () => import('../views/system/TenantManagementView.vue'), // 租户管理 (超管)
        },
        {
          path: 'user-permission',
          name: 'userPermission',
          component: () => import('../views/system/UserPermissionView.vue'), // 用户权限 (检验所)
        },
        {
          path: 'knowledge-base',
          name: 'knowledgeBase',
          component: () => import('../views/knowledge/KnowledgeBaseView.vue'), // 知识库管理
        },
        {
          path: 'knowledge-documents',
          name: 'knowledgeDocuments',
          component: () => import('../views/knowledge/KnowledgeDocumentsView.vue'), // 知识库文档列表
        },
        {
          path: 'report-generation',
          name: 'reportGeneration',
          component: () => import('../views/report/ReportGenerationView.vue'), // 报告生成
        },
        {
          path: 'report-collaboration',
          name: 'reportCollaboration',
          component: () => import('../views/report/ReportCollaborationView.vue'), // 报告协同与共享
        },
        {
          path: 'quality-control',
          name: 'qualityControl',
          component: () => import('../views/report/QualityControlView.vue'), // 审核与质控
        },
        {
          path: 'report-list',
          name: 'reportList',
          component: () => import('../views/report/ReportListView.vue'), // 报告列表
        },
        {
          path: 'report-detail/:id',
          name: 'reportDetail',
          component: () => import('../views/report/ReportDetailView.vue'), // 报告详情
        },
        {
          path: 'patient-report',
          name: 'patientReport',
          component: () => import('../views/patient/PatientReportView.vue'), // 患者报告查看
        },
        {
          path: 'medical-qa',
          name: 'medicalQA',
          component: () => import('../views/medical/MedicalQAView.vue'), // 医学检测问答
        },
      ],
    },
    {
      path: '/knowledge/documents',
      name: 'KnowledgeDocuments',
      component: () => import('@/views/knowledge/KnowledgeDocumentsView.vue'),
      meta: {
        title: '知识库文档管理',
        requiresAuth: true,
      },
    },
    {
      path: '/knowledge/documents/:id',
      name: 'KnowledgeDocumentDetail',
      component: () => import('@/views/knowledge/KnowledgeDocumentDetailView.vue'),
      meta: {
        title: '文档详情',
        requiresAuth: true,
      },
    },
    // 可以添加 404 页面等
  ],
})

export default router
